package com.tms.ned.controlmonitor.validate;

/*
 * Licensed under the Apache License, Version 2.0;<br> 
 * 
 * You may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless 
 * required by applicable law or agreed to in writing, software distributed under the License 
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and limitations under the License. 
 */


public class ValidationStatus {
  public static final ValidationStatus VALID = new ValidationStatus(true, false, "");
  private boolean isValid = false;
  private boolean isWarning = false;
  private String message = "";


  public ValidationStatus(boolean isValid) {
    this.isValid = isValid;
  }

  public ValidationStatus(boolean isValid, String message) {
    this(isValid, false, message);
  }


  public ValidationStatus(boolean isValid, boolean isWarning) {
    this(isValid, isWarning, "");
  }

  public ValidationStatus(boolean isValid, boolean isWarning, String message) {
    this.isValid = isValid;
    this.message = message;
    this.isWarning = isWarning;
  }

  public boolean isValid() {
    return isValid;
  }

  public void setValid(boolean flag) {
    isValid = flag;
  }

  public boolean isWarning() {
    return isWarning;
  }

  public void setWarning(boolean f) {
    isWarning = f;
  }

  public String getMessage() {
    return this.message;
  }

  public String toString() {
    return String.valueOf(message);
  }

  public boolean equals(Object o) {
    if(! (o instanceof ValidationStatus)) {
      return false;
    }

    ValidationStatus other = (ValidationStatus)o;
    if(other.isValid == this.isValid && other.message.equalsIgnoreCase(this.message))
      return true;
    else
      return false;
  }

}